﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace vmlModel.Entities
{
    public class vmlShape : vmlPathShapeBase
    {
        //public string Path { get { return (vmlObjElement.Attribute("path") != null) ? vmlObjElement.Attribute("path").Value : ""; } }
         public string vmlType { get { return (vmlObjElement.Attribute("type") != null) ? vmlObjElement.Attribute("type").Value.Replace("#","") : ""; } }
         private vmlShapeType _ShapeType;
         public vmlShapeType ShapeType
         {
             get { return _ShapeType; }
             set {
                 //-------------------
                 value.vmlObjElement.SetAttributeValue("height", ((this.Height) / vmlUtils.PixelPerPoint).ToString() + "pt");
                 value.vmlObjElement.SetAttributeValue("width", ((this.Width) / vmlUtils.PixelPerPoint).ToString() + "pt");
                 //value.RecalculateFormulas();
                 _ShapeType = value ;
                 this.Formulas = value.Formulas;
                 this.Stroke = value.Stroke;
                 this.SubPaths = value.SubPaths;
             }
         }
         public vmlShape()
         {

         }
         public vmlShape(XElement _vmlObjElement)
             : base(_vmlObjElement)
         {
             
         }
         public void PreparePathForDrawing()
         {
             foreach (var subPath in SubPaths)
             {


                 foreach (var cmd in subPath.PathCommands)
                 {
                     cmd.AdjustPointsForDrawing(Width / this.ShapeType.coordsize.Width, Height / this.ShapeType.coordsize.Height);
                 }
             }

         }

     }
}
